package com.north.light.libpicselect.bean;

import com.north.light.libpicselect.utils.LibPicPicDirectoryUtils;

import java.io.Serializable;

/**
 * create by lzt
 * data 2019/12/8
 * 图片or视频的信息
 * change by lzt 20200823 增加数据类型的变量
 */
public class LibPicInfo implements Serializable {
    private String name;//文件名
    private String path;//文件路径
    private SelInfo isSelect = new SelInfo();
    private int date;//日期__修改日期
    private int source;//1图片 2视频
    private String sourceFormat;//类型附属格式

    //通过本地处理获取的参数-------------------------------------------------------------------
    //视频的时长
    private long duration = 0;
    //资源的宽高
    private int width;
    private int height;


    private String directory;//目录
    private long directoryCount;//目录下文件个数

    public String getSourceFormat() {
        return sourceFormat;
    }

    public void setSourceFormat(String sourceFormat) {
        this.sourceFormat = sourceFormat;
    }

    public int getWidth() {
        return width;
    }

    public void setWidth(int width) {
        this.width = width;
    }

    public int getHeight() {
        return height;
    }

    public void setHeight(int height) {
        this.height = height;
    }

    public LibPicInfo() {
    }

    public LibPicInfo(String name, String path, int date,
                      long duration, int width, int height,
                      String format, int source) {
        this.name = name;
        this.path = path;
        this.directory = LibPicPicDirectoryUtils.getDirectory(path);
        this.date = date;
        this.source = source;
        this.duration = duration;
        this.width = width;
        this.height = height;
        this.sourceFormat = format;
    }

    public SelInfo getIsSelect() {
        return isSelect;
    }

    public void setIsSelect(SelInfo isSelect) {
        this.isSelect = isSelect;
    }

    public long getDuration() {
        return duration;
    }

    public void setDuration(long duration) {
        this.duration = duration;
    }

    public int getSource() {
        return source;
    }

    public void setSource(int source) {
        this.source = source;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public String getDirectory() {
        return directory;
    }

    public void setDirectory(String directory) {
        this.directory = directory;
    }

    public void setDirectoryCount(long directoryCount) {
        this.directoryCount = directoryCount;
    }

    public long getDirectoryCount() {
        return directoryCount;
    }

    public boolean isSelect() {
        return isSelect.isSel();
    }

    public long getSelTime() {
        return isSelect.getSelTime();
    }

    public void setSelect(boolean select) {
        isSelect.setSel(select);
        if (select) {
            isSelect.setSelTime(System.currentTimeMillis());
        } else {
            isSelect.setSelTime(0);
            isSelect.setIndex(-1);
        }
    }

    public int getDate() {
        return date;
    }

    public void setDate(int date) {
        this.date = date;
    }

    /**
     * 选择时间
     */
    public class SelInfo implements Serializable {
        private boolean isSel = false;
        private long selTime = 0;
        //选择的序号--没有则为-1
        private int index = -1;

        public int getIndex() {
            return index;
        }

        public void setIndex(int index) {
            this.index = index;
        }

        public boolean isSel() {
            return isSel;
        }

        public void setSel(boolean sel) {
            isSel = sel;
        }

        public long getSelTime() {
            return selTime;
        }

        public void setSelTime(long selTime) {
            this.selTime = selTime;
        }
    }
}
